package org.water.garden.activity.account;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Im.Account;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ActivityIconAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;

/**
 * @author sshwsfc@gmail.com
 * 
 * Add Acount Activity
 */
public class AccountAdd extends ListActivity {

	private ListAdapter adapter;
	
	protected void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		adapter = new ActivityIconAdapter(this, getTargetIntent());
		setListAdapter(adapter);
	}

	protected void onListItemClick(ListView l, View v, int position, long id) {
		Intent intent = ((ActivityIconAdapter) adapter).intentForPosition(position);
		startActivity(intent);
	}

	protected Intent getTargetIntent() {
		Intent intent = new Intent(Intent.INSERT_ACTION);
		intent.setType(Account.CONTENT_TYPE);
		return intent;
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode,
			String data, Bundle extras) {
		setResult(resultCode, data, extras);
		finish();
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		finish();
		return super.onTouchEvent(event);
	}
}